package com.htsk.city.services.core.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.htsk.city.services.core.utils.InstantToMillisSerializer;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.math.BigDecimal;
import java.time.Instant;

@Getter
@Setter
@Entity
@Table(name = "order_master")
public class OrderMaster {
    @Id
    @Column(name = "order_id", nullable = false)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Size(max = 32)
    @NotNull
    @Column(name = "order_no", nullable = false, length = 32)
    private String orderNo;

    @Size(max = 32)
    @NotNull
    @Column(name = "app_id", nullable = false, length = 32)
    private String appId;

    @Size(max = 64)
    @NotNull
    @Column(name = "openid", nullable = false, length = 64)
    private String openid;

    @NotNull
    @Column(name = "user_id", nullable = false)
    private Long userId;

    @Column(name = "user_mobile")
    private String userMobile;

    @NotNull
    @Column(name = "order_status", nullable = false)
    private Byte orderStatus;

    @NotNull
    @Column(name = "total_amount", nullable = false, precision = 10, scale = 2)
    private BigDecimal totalAmount;

    @NotNull
    @Column(name = "pay_amount", nullable = false, precision = 10, scale = 2)
    private BigDecimal payAmount;

    @Column(name = "discount_amount", precision = 10, scale = 2)
    private BigDecimal discountAmount;

    @Column(name = "freight_amount", precision = 10, scale = 2)
    private BigDecimal freightAmount;

    @Column(name = "pay_type")
    private Byte payType;

    @Column(name = "pay_time")
    @JsonSerialize(using = InstantToMillisSerializer.class)
    private Instant payTime;

    @Size(max = 64)
    @Column(name = "transaction_id", length = 64)
    private String transactionId;

    @Size(max = 32)
    @Column(name = "delivery_company", length = 32)
    private String deliveryCompany;

    @Size(max = 32)
    @Column(name = "delivery_no", length = 32)
    private String deliveryNo;

    @Column(name = "delivery_time")
    @JsonSerialize(using = InstantToMillisSerializer.class)
    private Instant deliveryTime;

    @Column(name = "receive_time")
    @JsonSerialize(using = InstantToMillisSerializer.class)
    private Instant receiveTime;

    @Size(max = 500)
    @Column(name = "remark", length = 500)
    private String remark;

    @Column(name = "source")
    private Byte source;

    @Column(name = "is_deleted")
    private Byte isDeleted;

    @NotNull
    @Column(name = "create_time", nullable = false)
    @JsonSerialize(using = InstantToMillisSerializer.class)
    private Instant createTime;

    @NotNull
    @Column(name = "update_time", nullable = false)
    @JsonSerialize(using = InstantToMillisSerializer.class)
    private Instant updateTime;

}